<?php

/*************************************************************************
 *
 *  System Name     ： UI TOOL
 *  Include Name  	： class.javascript.php
 *  Include IＤ		： javascript
 *
 *  Writer          ： Minz
 *  Create Date		： 2011/10/20
 *
 *************************************************************************/

class JSClass
{
	var $numbers_rand;

	//JavaScript Mess

	function msg($txt)
	{
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
		echo "
		<script language=\"javascript\">
		alert('$txt');
		</script>";
		exit;
	}

	function msg_go($txt = "",$f = "-1",$exit = 1)
	{
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
		echo "<script language=\"javascript\">";
		if( $txt )
		{
			echo "alert('$txt');";
		}
		echo "history.go($f);";
		echo "</script>";
		if($exit == "1") exit;
	}

	function msg_replace($txt,$url)
	{
		echo "
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
		<script language=\"javascript\">
		alert('$txt');
		document.location.replace('$url');
		</script>";
		exit;
	}

	function replace($url)
	{
		echo "
		<script language=\"javascript\">
		document.location.replace('$url');
		</script>";
		exit;
	}

	function msg_location($txt, $url)
	{
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
		echo "
		<script language=\"javascript\">
		alert('$txt');
		document.location='$url';
		</script>";
		exit;
	}

	function location($url)
	{
		echo "
		<script language=\"javascript\">
		document.location='$url';
		</script>";
		exit;
	}

	function reload()
	{
		echo "
		<script language=\"javascript\">
		document.location.reload();
		</script>";
		exit;
	}

	function opener_reload()
	{
		echo "
		<script language=\"javascript\">
		opener.location.reload();
		</script>";
		//exit;
	}

	function frame_reload($fr)
	{
		echo "
		<script language=\"javascript\">
		parent.".$fr.".document.location.reload();
		</script>";
	}

	function parent_replace($url)
	{
		echo "
		<script language=\"javascript\">
		parent.document.location.replace('$url');
		</script>";
		//exit;
	}

	function parent_reload()
	{
		echo "
		<script language=\"javascript\">
		parent.document.location.reload();
		</script>";
		//exit;
	}

	function close()
	{
		echo "
		<script language=\"javascript\">
		window.close();
		</script>";
	}

	function msg_reload($msg)
	{
		echo "
		<script language=\"javascript\">
		document.location.reload();
		</script>";
		exit;
	}

	function msg_close($txt, $t = 0, $reurl = "")
	{
		if( $t == 0 )
		{
			echo "
			<script language=\"javascript\">
			alert('$txt');
			window.close();
			</script>";
			exit;
		}
		else if( $t == 1 )
		{
			echo "
			<script language=\"javascript\">
			alert('$txt');
			window.close();
			opener.document.location.reload();
			</script>";
			exit;
		}
		else if( $t == 2 )
		{

			echo "
			<script language=\"javascript\">
			alert('$txt');
			opener.document.location.replace('$reurl');
			window.close();
			</script>";
			exit;
		}

	}

	//meta　Tag　refresh
	function refresh($url, $time = 0)
	{
		echo "<meta http-equiv='refresh' content='".$time.";url=$url'>";
		exit;
	}

	function confirm($msg,$url)
	{
		echo "
		<script language=\"javascript\">

		if(confirm('$msg'))
		{
			document.location.replace('$url');
		}
		else
		{
			history.go(-1);
		}
		</script>";
		exit;
	}


	function confirm_replace($msg,$url, $reurl)
	{
		echo "
		<script language=\"javascript\">

		if(confirm('$msg'))
		{
			document.location.replace('$url');
		}
		else
		{
			document.location.replace('$reurl');
		}
		</script>";
		exit;
	}

	function confirm_reload($msg)
	{
		echo "
		<script language=\"javascript\">

		if(confirm('$msg'))
		{
			document.location.reload();
		}
		else
		{
			history.go(-1);
		}
		</script>";
		exit;
	}

	function scriptExe( $msg )
	{
		echo "<script language=\"javascript\">";
		echo $msg;
		echo "</script>";
		exit;
	}

}

if(!is_object( $JSClass ))
{
	$JSClass = new JSClass;
}
?>
